fix: prioritize deno
and workerd
conditions over node
condition
#16
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This one isn't a big deal but when using esbuild to bundle a Cloudflare Worker, I usually add the
workerd
condition to my esbuild config to get my dependencies to use worker-compatible versions. However, when using@libsql/client/web
, the build fails with errorno such module 'node:http
which is imported in thenode
export ofisomorphic-fetch
. To fix this, I addplatform: browser
to my config, forcing it to use theweb
export of isomorphic-fetch.The build then fails with
could not resolve module node:crypto
(or any compatible node builtin as these don't exist in a browser environment. To fix this I have to externalise all node builtins I may be using so my esbuild config ends up being:Dependencies may also be using node builtins internally so what I end up usually doing is:
This happens because of the ordering of the
export
in the package.json, where thenode
condition takes precedence over theworkerd
condition. This PR simply swaps the priority. Here's an excerpt from the Conditional Export docs:Not sure what side effects this change may cause so feel free to close it if it breaks something, would just be nice to not have to do this on every project using this with esbuild and have everything configurable with just
conditions
.